import axios from 'axios'


const request = axios.create({
	timeout: 5000
})


request.interceptors.request.use(config => {
	config.headers.token = 'XXXXXXXXXXXXXXXXX'
	return config
}, err => {
	return Promise.reject(err)
})

request.interceptors.response.use(response => {
	const { code } = response.data
	if(code === '404') console.log('资源找不到 ')
	if(code === '500') console.log('服务器错误')
	if(code === '401') console.log('没有token')
	if(code === '403') console.log('没有权限')

	return response
}, err => {
	return Promise.reject(err)
})


export default request